package com.atm.controller;

import com.atm.annotation.NeedLogin;
import com.atm.config.Const;
import com.atm.entity.CashLog;
import com.atm.entity.DepositLog;
import com.atm.entity.TransferLog;
import com.atm.service.LogService;
import com.atm.utils.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Api(tags = "流水")
@RestController
public class LogController {
    @Resource
    private LogService logService;

    @ApiOperation("查询取款记录")
    @NeedLogin
    @PostMapping("/cashLog")
    public Result<List<CashLog>> showCashLog(HttpServletRequest httpServletRequest){

        return logService.showCashLog(httpServletRequest.getAttribute(Const.AccountNo).toString());
    }

    @ApiOperation("查询存款记录")
    @NeedLogin
    @PostMapping("/depositLog")
    public Result<List<DepositLog>> showDepositLog(HttpServletRequest httpServletRequest){

        return logService.showDepositLog(httpServletRequest.getAttribute(Const.AccountNo).toString());
    }

    @ApiOperation("查询转账记录")
    @NeedLogin
    @PostMapping("/transferLog")
    public Result<List<TransferLog>> showTransferLog(HttpServletRequest httpServletRequest){

        return logService.showTransferLog(httpServletRequest.getAttribute(Const.AccountNo).toString());
    }
}
